/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * <p>Project: javaseapp - IntStream1
 * <p>Powered by webrx On 2021-08-20 17:35:46
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class IntStream1 {
    public static void main(String[] args) {
        Random rand = new Random();
        IntStream is = IntStream.generate(() -> rand.nextInt(100) + 1).limit(6);
        //is.forEach(System.out::println);
        //is.forEachOrdered(System.out::println);
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(6);
        list.add(2);
        //list.stream().forEachOrdered(System.out::println);
        Stream<Integer> si = list.stream();
        //si.count()
        System.out.println(si.max(Comparator.comparingInt(a -> a)).get());

        //奇数
        IntStream.iterate(1, e -> e + 2).limit(6).forEach(e -> {
            System.out.printf("%d ,", e);
        });

        System.out.println();
        //forEachOrdered


    }
}
